// GCC零长数组示例
#include <cstdlib>
#include <cstring>
#include <iostream>

using namespace std;

struct line {
    int length;
    char contents[0]; // C99的玩法是：char contents[]; 没有指定数组长度
};

struct one {
    int length;
    char contents[1];
};

int main(int argc, char **argv) {
    int length = 10;
    line *demo = (line *)malloc(sizeof(line) + length);
    demo->length = length;
    memset(demo->contents, 'a', demo->length);

    cout << "line:\n\t";
    for (int i = 0; i < demo->length; i++) {
        cout << demo->contents[i];
    }
    cout << endl;

    cout << "sizeof(int): " << sizeof(int) << endl;
    cout << "sizeof(one): " << sizeof(one) << endl;

    return 0;
}
